package com.hashnode._901dockerspringboottest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CounterController {

    private int i = 0;

    @Autowired
    StringRedisTemplate redisTemplate;


    @GetMapping("/hello")
    public String count(){
        Long increment = redisTemplate.opsForValue().increment("count-people");
        return "有"+ increment + "人访问了这个页面";
    }

    @GetMapping("/hello1")
//    @ResponseBody
    public String count2(){
        return "有"+  "人访问了这个页面";
    }
}
